package LuoGu;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.StreamTokenizer;

public class P3156 {
    public static void main(String[] args) throws IOException {
        StreamTokenizer st=new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
        st.nextToken();
        int N=(int)st.nval;
        st.nextToken();
        int n=(int)st.nval;
        int[] arr=new int[N];
        for (int i = 0; i < N; i++) {
           st.nextToken();
           arr[i]=(int)st.nval;
        }
        int[] find=new int[n];
        for (int i = 0; i < n; i++) {
            st.nextToken();
            find[i] = (int) st.nval;
        }
        for (int i = 0; i < n; i++) {
            System.out.println(arr[find[i]-1]);
        }

    }
}
